#include "CReflectTest.h"

CStatic::CStatic()
{
    m_BrushColor = 0;
    m_FrontColor = 0;
    m_BackColor = 0;
    m_hBrush = nullptr;
}

CStatic::CStatic(COLORREF BrushColor, COLORREF FrontColor, COLORREF BackColor) :
    m_BrushColor(BrushColor),
    m_FrontColor(FrontColor),
    m_BackColor(BackColor)
{
    m_hBrush = CreateSolidBrush(BrushColor);
}

CStatic::~CStatic()
{
}

void CStatic::OnFinalMessage(HWND hWnd)
{
    if (m_hBrush)
        ::DeleteObject(m_hBrush);
}

LRESULT CStatic::OnColorHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    HDC hDC = (HDC)wParam;
    HWND hWnd = (HWND)lParam;

    SetTextColor(hDC, m_FrontColor);
    SetBkColor(hDC, m_BackColor);
    return (LRESULT)m_hBrush;
}


CReflectTest::CReflectTest() : 
    m_Static(COLORREF(RGB(255, 0, 0)), COLORREF(RGB(0, 0, 255)), COLORREF(RGB(255, 0, 0)))
{
}

CReflectTest::~CReflectTest()
{
}

LRESULT CReflectTest::OnDestroyHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    PostQuitMessage(0);
    return 0;
}

LRESULT CReflectTest::OnCreateHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    RECT rc = { 0,0,100,20 };
    m_Static.Create(m_hWnd, rc, L"static", WS_CHILD | WS_VISIBLE);
    CenterWindow();
    return 0;
}
